import Environment from "./environment";
import $ from "jquery";

function loadJson(sdcard,path, callback, error) {

   // alert(sdcard);

    if (Environment.useLocaleData()) {
        let josnobj = null;
        try {
            let str = JavaContext.ReadTxtFile(path);
            str  =  str.replace(/SdcardNumber/g,function() {
                let number = sdcard;
                return number;
            });
           josnobj = eval('(' + str + ')');


        } catch (e) {
            if (error) {
                error(e);
            }
        }
        callback(josnobj);
    } else {
        //$.getJSON(Environment.getDataBasePath() + path,callback);
        $.ajax({
            async: false,
            type: "get",
            url: path,
            dataType: "json",
            success: callback,
            error: error
        });
    }
}
export default loadJson;
